<?php

// 8/29/2009: immanuel192 add file_id field to support logo image of the linklist
// Change logs
/**
* Feb 11, 2011 -trungdt - Add featuretabs and banner mode
*                         Add remove html in body mode
*                         When in this mode, we show textarea, not html text editor
* 
* 
*/
class linklist_link {
	function form($object, $config) {
		if (!defined('SYS_FORMS')) require_once(BASE.'subsystems/forms.php');
		exponent_forms_initialize();

		$form = new form();
		if (!isset($object->id)) {
			$object->name = '';
			$object->url = '';
			$object->description = '';
			$object->opennew = 0;
            $object->file_id=0;
            $object->post_date=0;
            $object->detail_title='';
			$object->view_style=0;
		} else {
			$form->meta('id',$object->id);
		}
        $lang = exponent_lang_loadFile("datatypes/linklist_link.php");
        //$config->remove_body_html=1;
        if ($config->name_multiline == 1)
        {
            $form->register('name',$lang['name'],new texteditorcontrol($object->name,5,77));
        }
        else
        {
            $form->register('name',$lang['name'],new textcontrol($object->name));
        }
        
        
        
        $form->register('detail_title',$lang['title'],new textcontrol($object->detail_title));
        $form->register("",null, new htmlcontrol($lang['description1']));
        
        // view style
        $view_style_combo = array();
        $view_style_combo[0]=$lang['link_to'];
        $view_style_combo[1]=$lang['show_content'];
        
        $form->register('view_style',$lang['item_style'],new dropdowncontrol($object->view_style,$view_style_combo));
         $form->register('sef_name','Sef name',new textcontrol($object->sef_name));
		$form->register('url','URL',new textcontrol($object->url));
		$form->register('file_id',$lang['image'], new ajax_select_file("file_id",0,$object->file_id,true));
		$form->register('opennew',$lang['open_new_win'],new checkboxcontrol($object->opennew,true));
       
       if($config->name_multiline==1)
        {
            $form->register('body2',$lang['short_des'],new texteditorcontrol($object->body2, 3, 75)); 
        }
        
         if ($config->remove_body_html==1){
            $form->register('description',$lang['description'],new  texteditorcontrol($object->description,10,40));
        }
        else
        {
            $form->register('description',$lang['description'],new htmleditorcontrol($object->description));   
        }
        
        if (!isset($object->id))
            $form->register('post_date',$lang['post_date'],new yuidatetimecontrol($object->post_date,"", true, true, false, false));
            
		$form->register('submit','',new buttongroupcontrol($lang['save'],'',$lang['cancel']));
		return $form;
	}

	function update($values,$object) {
        $object->name = $values['name'];
		$object->detail_title = $values['detail_title'];
        $object->view_style = intval($values['view_style']);
		$object->url = $values['url'];
		$object->file_id = $values['file_id'];
		$object->opennew = (isset($values['opennew']) ? 1 : 0);
		$object->description = $values['description'];
        $object->body2 = $values['body2'];
        if($values['sef_name']=="")
         $object->sef_name=_to_vietnamese_with_nomark($values['name']);
         else
         $object->sef_name=str_replace(' ',"-",$values['sef_name']);
        
        if (!isset($object->id))
        {
            $object->post_date = yuidatetimecontrol::parseData('post_date',$values);
        }
        if ($object->post_date == 0)
            $object->post_date = time();
        //$post_date = strtotime($values['post_datedate']);
        //$object->post_date = ($post_date);
		return $object;
	}
    
}

?>
